<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <style>

    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">{{thtitle}}</div>
      </div>
      <!--  -->
      <!--  -->
      <div class="x-pro-list">
        <div class="x-pro-row">
          <div class="x-pro-label">反馈时间:</div>
          <div class="x-pro-input">
            <el-date-picker v-model="feedtime" type="date" placeholder="选择日期" :editable="notkey" format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd" :disabled="isfromindex"></el-date-picker>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">反馈店面:</div>
          <div class="x-pro-input">
            <el-select v-model="feedstore" placeholder="请选择" :disabled="isfromindex">
              <el-option v-for="item in storedata" :key="item.id" :label="item.title" :value="item.id"></el-option>
            </el-select>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">内容类型:</div>
          <div class="x-pro-input">
            <el-select v-model="feedtype" placeholder="请选择" :disabled="isfromindex">
              <el-option v-for="item in typedata" :key="item.id" :label="item.title" :value="item.id"></el-option>
            </el-select>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">反馈方式:</div>
          <div class="x-pro-input">
            <el-select v-model="feedway" placeholder="请选择" :disabled="isfromindex">
              <el-option v-for="item in waydata" :key="item.id" :label="item.title" :value="item.id"></el-option>
            </el-select>
          </div>
        </div>
        <div class="x-pro-row x-pro-rowblock">
          <div class="x-pro-label">反馈内容:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="feedpro" type="textarea" :rows="4" :disabled="isfromindex"></el-input>
          </div>
        </div>
        <div class="x-pro-row x-pro-rowblock">
          <div class="x-pro-label">反馈追踪:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="feedcon" type="textarea" :rows="4" :disabled="isfromindex"></el-input>
          </div>
        </div>
      </div>
      <!--  -->
      <div class="x-pro-gobtn" @click="isok" v-if="thtype=='1'">提交</div>
      <div class="x-pro-gobtn" @click="isoktwo" v-if="thtype=='2'">编辑</div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));
    var tmonth = api.pageParam.date;
    var ttype = api.pageParam.type;
    var tlistdesc = api.pageParam.listdesc;
    console.log(JSON.stringify(tlistdesc));
    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
            thtitle:'',
            thmonth:'',
            thtype:'',
            feedtime:'',
            feedstore:'',
            feedtype:'',
            feedway:'',
            feedpro:'',
            feedcon:'',
            isfromindex:false,
            storedata:'',
            typedata:'',
            waydata:'',
            notkey:false,
            thlistdesc:'',
            isedit:false,
            listid:'',

        }
      },
      created:function() {
        var that=this;
        that.thmonth = tmonth;
        that.thtype = ttype;
        if(that.thtype == '1'){//新增
            that.thtitle = '添加新反馈';
        }else if(that.thtype == '2'){//编辑
            that.thlistdesc = tlistdesc;
            that.thtitle = that.thlistdesc.shop_title;
            that.feedtime = that.thlistdesc.fb_time;
            that.feedstore = that.thlistdesc.shopid;
            that.feedtype = that.thlistdesc.cateid;
            that.feedway = that.thlistdesc.typeid;
            that.feedpro = that.thlistdesc.content;
            that.feedcon = that.thlistdesc.track_content;
            that.listid = that.thlistdesc.id;

        }else if(that.thtype == '3'){//查看
            that.isfromindex = true;
            that.thlistdesc = tlistdesc;
            that.thtitle = that.thlistdesc.shop_title;
            that.feedtime = that.thlistdesc.fb_time;
            that.feedstore = that.thlistdesc.shopid;
            that.feedtype = that.thlistdesc.cateid;
            that.feedway = that.thlistdesc.typeid;
            that.feedpro = that.thlistdesc.content;
            that.feedcon = that.thlistdesc.track_content;
            that.listid = that.thlistdesc.id;

        }

      },
      mounted:function(){
        var that=this;
        that.getstoredata()// 店面data
        that.gettypedata()//类型data
        that.getwaydata()//方式data

      },
      methods: {
        isok:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/patrol/addFeedback',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.thmonth,
                fb_time:that.feedtime,
                shopid:that.feedstore,
                cateid:that.feedtype,
                typeid:that.feedway,
                content:that.feedpro,
                track_content:that.feedcon
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.sendEvent({
                    name: 'addFeedback',
                    extra: {
                    }
                });
                api.confirm({
                    title: '提交成功',
                    msg: '',
                    buttons: ['继续编辑', '返回']
                }, function(ret, err) {
                    var index = ret.buttonIndex;
                    if(index=='1'){

                    }else{
                      api.closeWin({});

                    }
                });
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //编辑
        isoktwo:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/patrol/editFeedback',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                id:that.listid,
                fb_time:that.feedtime,
                shopid:that.feedstore,
                cateid:that.feedtype,
                typeid:that.feedway,
                content:that.feedpro,
                track_content:that.feedcon
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.sendEvent({
                    name: 'addFeedback',
                    extra: {
                    }
                });
                api.confirm({
                    title: '编辑成功',
                    msg: '',
                    buttons: ['继续编辑', '返回']
                }, function(ret, err) {
                    var index = ret.buttonIndex;
                    if(index=='1'){

                    }else{
                      api.closeWin({});

                    }
                });
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        // 店面data
        getstoredata:function(){
            let that=this;
            api.ajax({
                url:baseurl+'api/company/shopList',
                methods:'get',
                data:{
                values:{
                    sec: $api.getStorage('apptoken')
                    }
                }
            },function(ret,err){
                if(ret){
                api.hideProgress();
                // console.log(JSON.stringify(ret));
                if(ret.status == 1){
                    that.storedata = ret.data;
                }else{
                    api.toast({
                        msg: ret.msg,
                        duration: 3000,
                        location: 'bottom'
                    });
                }
                }else{
                api.hideProgress();
                console.log(JSON.stringify(err));
                api.toast({
                    msg: err.msg,
                    duration: 3000,
                    location: 'bottom'
                });
                }
            })
        },
        // 类型data
        gettypedata:function(){
            let that=this;
            api.ajax({
                url:baseurl+'api/patrol/feedbackCate',
                methods:'get',
                data:{
                values:{
                    sec: $api.getStorage('apptoken')
                    }
                }
            },function(ret,err){
                if(ret){
                api.hideProgress();
                // console.log(JSON.stringify(ret));
                if(ret.status == 1){
                    that.typedata = ret.data.list;
                }else{
                    api.toast({
                        msg: ret.msg,
                        duration: 3000,
                        location: 'bottom'
                    });
                }
                }else{
                api.hideProgress();
                console.log(JSON.stringify(err));
                api.toast({
                    msg: err.msg,
                    duration: 3000,
                    location: 'bottom'
                });
                }
            })
        },
        // 方式data
        getwaydata:function(){
            let that=this;
            api.ajax({
                url:baseurl+'api/patrol/feedbackType',
                methods:'get',
                data:{
                values:{
                    sec: $api.getStorage('apptoken')
                    }
                }
            },function(ret,err){
                if(ret){
                api.hideProgress();
                // console.log(JSON.stringify(ret));
                if(ret.status == 1){
                    that.waydata = ret.data.list;
                }else{
                    api.toast({
                        msg: ret.msg,
                        duration: 3000,
                        location: 'bottom'
                    });
                }
                }else{
                api.hideProgress();
                console.log(JSON.stringify(err));
                api.toast({
                    msg: err.msg,
                    duration: 3000,
                    location: 'bottom'
                });
                }
            })
        },
      }
    })
	}


	</script>
</body>
</html>
